(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as anonymous module.
        define(['jquery'], factory);
    } else if (typeof exports === 'object') {
        // Node / CommonJS
        factory(require('jquery'));
    } else {
        // Browser globals.
        factory(jQuery);
    }
})(function ($) {
    'use strict';
    /*
    * 注意：
    * 样式表需添加 flashing 类，通过改变样式来实现闪烁
     .flashing{background-color:#f00 !important;}
     */
    $.fn.extend({
        "startFlashing":function () {
            var $this = $(this);
            var flashingId = $this.data('flashing');
            if (flashingId)  clearInterval(flashingId);           
            flashingId = setInterval(function (){
                if ($this.hasClass('flashing')){
                    $this.removeClass('flashing');
                } else {
                    $this.addClass('flashing');
                }
            },1000);
            $this.data('flashing',flashingId);
        },
        "stopFlashing":function () {
            var $this = $(this);
            var flashingId = $this.data('flashing');
            if (flashingId)  clearInterval(flashingId); 
            $.removeData('flashing');
            $this.removeClass('flashing');
            return this;
        }
    });
});